<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>新增-网站后台管理系统</title>
	<meta name="keywords" content="网站后台管理系统">
	<meta name="description" content="网站后台管理系统">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black"> 
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="../../layui/css/layui.css" media="all">
	<style>
	.popIframeBody {background: rgb(247,247,247);}
	.popIframeContent {padding:20px;background: rgb(255,255,255);}
	.popIframeBtn {padding:20px 0px;border-top:1px rgb(235,235,235) solid;text-align: center;}
	</style>
</head>
<body class="popIframeBody">
<form class="layui-form">
	<div class="popIframeContent">
	
		<div class="layui-form-item">
			<div class="layui-form-label">所属设备</div>
			<div class="layui-input-block">
				<select name="equipment_number_id" id="equipment_number_id" lay-filter="equipment_number_id" class="layui-input" required lay-verify="required">
	                        
	           </select>
			</div>
		</div>
	
		<div class="layui-form-item">
			<div class="layui-form-label">名称</div>
			<div class="layui-input-block">
				<input type="text" name="name" required lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input">
			</div>
		</div>
		
		<div class="layui-form-item">
			<div class="layui-form-label">批次号</div>
			<div class="layui-input-block">
				<input type="text" name="batch_number" required lay-verify="required" placeholder="请输入批次号" autocomplete="off" class="layui-input">
			</div>
		</div>
		
		<div class="layui-form-item">
			<div class="layui-form-label">台份号</div>
			<div class="layui-input-block">
				<input type="text" name="batch_count" required lay-verify="required" placeholder="请输入台份号" autocomplete="off" class="layui-input">
			</div>
		</div>
		
	</div>
	<div class="popIframeBtn">
		<button class="layui-btn" lay-submit lay-filter="submit">保存</button>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
</body>
<script src="../../layui/layui.js" charset="utf-8"></script>
<script src="../../js/public.js" charset="utf-8"></script>
<script>
layui.use(['form','laydate','upload'], function(){
	var form = layui.form;
	var $ = layui.jquery;
	var laydate = layui.laydate;
	var upload = layui.upload;
	
	laydate.render({
	    elem: '#data_time'
	    ,type: 'datetime'
	    ,trigger: 'click'
	 });
	
	laydate.render({
	    elem: '#end_time'
	    ,type: 'date'
	    ,trigger: 'click'
	    	,format: 'yyyy年MM月dd日'
	 });
	
	
	
	$.ajax({
		url:"/equipment/queryList",
		type:'post',
		data:JSON.stringify({"page":1,"limit":100}),
		dataType:"json",//数据类型
		contentType: 'application/json',
		beforeSend: function () {
            //console.log(JSON.stringify(data.field));
        },
        success: function (resultData) {
        	 $("#equipment_number_id").empty();
        	if(resultData.code===0){
        		console.log(resultData.data);
        		$("#equipment_number_id").append(new Option("选择或搜索角色", ""));
                $.each(resultData.data, function(index, item) {
                	$('#equipment_number_id').append(new Option(item.equipment_name, item.equipment_number));
                });
            }else{
                $("#equipment_number_id").append(new Option("暂无数据", ""));
            }
        	form.render();
        }
	});
	
	
	
	 $('.btnxspz').on('click',function(){
     	/* layer.open({
     		type: 2,
     		shade: [0],
     		title: "验收申请",
     		area: ['600px','420px'],
     		btn: ['按钮1', '按钮2'], //只是为了演示
     		//time: 2000, //2秒后自动关闭
     		fixed: true,
     		shadeClose: false, //开启遮罩关闭
     		content: 'index.html',
     		yes: function (index, layero) {
     		//得到iframe页的窗口对象（2种方式）-----------推荐使用第二种方式获得对象
     		var iframeWin1 = window[layero.find('iframe')[0]['name']];
     		var iframeWin2 = window["layui-layer-iframe" + index];

     		//获取子页面的值
     		var res = iframeWin1.callbackdata ();
     		alert(res.resut4);　　//这里从子页面传过来了4个值，这里只取第四个值 callbackdata（）来自子页面
     		},
     		cancel: function (index, layero) {//取消事件
     		},
     		end: function () {//无论是确认还是取消，只要层被销毁了，end都会执行，不携带任何参数。layer.open关闭事件
     		location.reload();　　//layer.open关闭刷新
     		}
     		}); */
     	
     	layer.open({
             type: 2
             ,title: ['拍照',"font-size:16px;font-weight:bold"] 
             ,closeBtn: false
             ,area: ['100%','420px'] //高宽度
             ,shade: 0.8
             ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
             ,btn: ['确定', '取消']
             ,btnAlign: 'c'
             ,moveType: 1 //拖拽模式，0或者1
             ,content: 'index2.html'
             ,yes: function(index, layero){
             	var result = sessionStorage.getItem("image");
             	$('#demo1').attr('src', result);
             	$('input[name="img"]').attr("value",result);
             	console.log(result)
             	layer.close(index);
         		}
             ,success: function(layero){
	        		console.log("1231231")
             }
	        	 
           });
     		return false; 
     	
     	 layer.open({
     		skin: 'demo-class'//自定义样式
     		,type: 2 //内容形态
     		,shade: [0]
     		,title: ['拍照',"font-size:16px;font-weight:bold"] //不显示标题栏
     		,btn: ['按钮1', '按钮2'] //只是为了演示
     		,closeBtn: '1'//按钮样式
     		,area: ['600px','420px'] //高宽度
     		,shade: 0.5 //遮罩层
     		,maxmin :true //最大化
     		,anim: 0 //过渡动画
     		,id: 'LAY_layuipro' //设定一个id，防止重复弹出
     		,btn: false //按钮名称
     		,btnAlign: 'c'
     		,moveType: 1 //拖拽模式，0或者1
     		,content: 'index.html'
     		,yes: function(index, layero){
     			//执行保存方法
     			return false;
     		}
     		,success: function(layero){
     			//点击成功方法
     			return false;
     		}
     	});
     	return false; 
 	});
	
	
	
	upload.render({
        elem: '#test1'
        ,url: '/user/uploadImg'
        ,accept: 'images'
        ,before: function(obj){
          //预读本地文件示例，不支持ie8
          obj.preview(function(index, file, result){
            $('#demo1').attr('src', result); //图片链接（base64）
          });
        }
        ,done: function(res){
          //如果上传失败
          if(res.code > 0){
            return layer.msg('上传失败');
          }
          $('input[name="img"]').attr("value",res.data.picUrl);
          //上传成功
        }
        ,error: function(){
          //演示失败状态，并实现重传
          var demoText = $('#demoText');
          demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
          demoText.find('.demo-reload').on('click', function(){
            uploadInst.upload();
          });
        }
      });
	 
	//监听提交
	form.on('submit(submit)',function(data){
		SubmitTable('/product/add',data.field,'post',true,'tableList');
		return false;
	});
});
</script>
</html>